<ion-view view-title={{moduleTitle}}>
    <ion-nav-buttons side="left">
        <a class="button button-icon ion-arrow-left-c" ng-click="goBack()"></a>
    </ion-nav-buttons>
    <ion-side-menus>
    <div class="tabs-striped tabs-top">
        <div class="tabs">
            <a ng-if="access.list" ng-class="{'tab-item':true,'active': id }" href="#/{{moduleName}}/list">查看</a>
            <a ng-if="access.add" ng-class="{'tab-item':true,'active': !id }" href="#/{{moduleName}}/0">添加</a>
        </div>
    </div>
        <ion-side-menu-content class="padding has-tabs-top">
            <ion-content class="padding has-tabs-top">
                <form name="detailForm" novalidate="" ng-submit="submitForm(detailForm)">
                    <ion-list class="list">

                        <a class="item item-icon-right" menu-toggle="{{farmerInfo.menu_toggle}}">
                            农户<span style="color:red">*</span>&nbsp&nbsp{{farmerInfo.selected_farmer}}
                            <i ng-show="!farmerInfo.is_farmer" class="icon ion-ios-arrow-right"></i>
                        </a>
                        <label ng-show="false" class="item item-input">
                            <span class="input-label">农户ID：</span>
                            <input type="text" name="famer_id" ng-model="farmerInfo.farmer_id"
                                   required
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.famer_id.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>

                        <label class="item item-input">
                            <span class="input-label">实验标题：</span>
                            <input type="text" name="title" ng-model="detail.title"
                                   ng-maxlength="20"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.title.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-20.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">实验地点：</span>
                            <input type="text" name="location" ng-model="detail.location"
                                   ng-maxlength="50"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.location.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-50.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">送样人：</span>
                            <input type="text" name="sampler" ng-model="detail.sampler"
                                   ng-maxlength="20"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.sampler.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-20.html"></div>
                        </div>


                        <insert-date form="detailForm" dateoption="dateOption"></insert-date>
                        <insert-select form="detailForm" option="prePlantOption"></insert-select>
                        <insert-select form="detailForm" option="recPlantOption"></insert-select>

                        <label class="item item-input">
                            <span class="input-label">目标产量(千克/亩)：</span>
                            <input type="text" name="target_yield" ng-model="detail.target_yield"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.target_yield.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>


                        <label class="item item-input">
                            <span class="input-label">氮(mg/L)：</span>
                            <input type="text" name="nitrogen" ng-model="detail.nitrogen"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.nitrogen.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">磷(mg/L)：</span>
                            <input type="text" name="phosphorus" ng-model="detail.phosphorus"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.phosphorus.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>

                        <label class="item item-input">
                            <span class="input-label">钾(mg/L)：</span>
                            <input type="text" name="potassium" ng-model="detail.potassium"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.potassium.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">有机质(mg/L)：</span>
                            <input type="text" name="organicmatter" ng-model="detail.organicmatter"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.organicmatter.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">PH值：</span>
                            <input type="text" name="ph" ng-model="detail.ph"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.ph.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">钙(mg/L)：</span>
                            <input type="text" name="calcium" ng-model="detail.calcium"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.calcium.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">镁(mg/L)：</span>
                            <input type="text" name="magnesium" ng-model="detail.magnesium"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.magnesium.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">硫(mg/L)：</span>
                            <input type="text" name="sulfur" ng-model="detail.sulfur"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.sulfur.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">锌(mg/L)：</span>
                            <input type="text" name="zinc" ng-model="detail.zinc"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.zinc.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">铜(mg/L)：</span>
                            <input type="text" name="copper" ng-model="detail.copper"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.copper.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">铁(mg/L)：</span>
                            <input type="text" name="iron" ng-model="detail.iron"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.iron.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">硼(mg/L)：</span>
                            <input type="text" name="boron" ng-model="detail.boron"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.boron.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">锰(mg/L)：</span>
                            <input type="text" name="manganese" ng-model="detail.manganese"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.manganese.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <a class="item item-icon-left " ng-click="openFertilizerPopover($event)">
                            添加施肥推荐信息
                            <i class="icon ion-plus-circled"></i>
                        </a>
                        <ion-item ng-repeat="item in subFertilizerList | orderObjectById:'id':true">
                            <h2>{{item.fertilization_date}}</h2>
                            <p>施肥类型:{{ item.type }};化肥：{{ item.fertilizer_name }}</p>
                            <p>施肥数量（千克/亩）:{{ item.fertilizer_quantity }}</p>
                            <p>施肥方法:{{ item.fertilization_method }}</p>
                            <ion-option-button class="ion-minus-circled"
                                               ng-click="onItemDelete(item,$index,'fertilizer_recommendation')">
                            </ion-option-button>
                        </ion-item>
                    </ion-list>

                    <button class="button button-full button-positive" ng-disabled="detailForm.$invalid || detailEdit.editDisabled" type="submit">
                        {{operation}}
                    </button>
                </form>
            </ion-content>
        </ion-side-menu-content>
        <ion-side-menu expose-aside-when="large" side="right">
            <ion-content class="has-tabs-top padding">

                <div class="item item-divider text-center">
                    <a>选择农户</a>
                </div>

                <insert-address  addressoption="farmerAddressOption"></insert-address>
                <label class="item item-input">
                    <span class="input-label">农户姓名：</span>
                    <input type="text" ng-model="farmerInfo.farmer_name">
                </label>
                <!--<label class="item item-input">-->
                <!--<span class="input-label">手机号：</span>-->
                <!--<input type="text" ng-model="farmerInfo.cell">-->
                <!--</label>-->
                <!--<ion-content>-->
                <button class="button button-full button-positive" ng-click="filterFarmer()">查询</button>

                <div class="item item-divider text-center">
                    <a>农户列表</a>
                </div>

                <ion-list class="list" >
                    <ion-item menu-close ng-repeat="item in chooseFarmerList | orderObjectById:'farmer_id':true"
                              ng-click="setFarmer(item.farmer_id,item.farmer_name)">
                        <h2>{{item.province+item.city+item.county+item.town+item.village}}</h2>
                        <p>农户：{{ item.farmer_name }}</p>
                        <p>手机号：{{ item.cell }}</p>
                    </ion-item>

                    <div ng-if="listEnd" class="text-center">
                        已显示所有数据
                    </div>
                </ion-list>
                <ion-infinite-scroll ng-if="!listEnd" on-infinite="loadList(false)" distance="1%"></ion-infinite-scroll>

            </ion-content>
        </ion-side-menu>
    <!--头部和内容结束-->
    </ion-side-menus>
</ion-view>